<?php
//判断是否是pjax请求  

use function FC\url;

// 获取博客文章列表
function getArticleList($args = '')
{
	$obj = \FC\obj('\Main\Api\App\data');
	$query = $obj->query($args);
	$re = $obj->getArticleList($query);
	return $re ?? [];
}

// 获取博客文章分页列表
function getArticlePage($args = '')
{
	$obj = \FC\obj('\Main\Api\App\data');
	$query = $obj->query($args);
	$page = $obj->page['article'];
	return $obj->page($query, $page);
}

// 获取博客文章详情
function getArticleInfo($aid)
{
	if (empty($aid)) {
		return null;
	}
	$obj = \FC\obj('\Main\Api\App\data');
	$res = $obj->getArticleInfo($aid);
	return $res;
}

// 获取随机文章
function getRandArticle()
{
	$obj = \FC\obj('\Main\Api\App\data');
	$res = $obj->getRandArticle();
	return $res;
}

// 获取分类列表
function getClassList($args = '')
{
	$obj = \FC\obj('\Main\Api\App\data');
	$query = $obj->query($args);
	$re = $obj->getClassList($query);
	return $re ?? [];
}

// 获取
function getClassTitle(int $cid)
{
	$obj = \FC\obj('\Main\Api\App\data');
	return $obj->getClassTitle($cid);
}

// 获取微语列表
function getWeiyuList($args = '')
{
	$obj = \FC\obj('\Main\Api\App\data');
	$query = $obj->query($args);
	$re = $obj->getWeiyuList($query);
	return $re ?? [];
}

// 获取微语分页
function getWeiyuPage($args = '')
{
	$obj = \FC\obj('\Main\Api\App\data');
	$query = $obj->query($args);
	$page = $obj->page['weiyu'];
	return $obj->page($query, $page);
}

// 获取友链列表
function getLinksList($args = '')
{
	$obj = \FC\obj('\Main\Api\App\data');
	$query = $obj->query($args);
	$re = $obj->getLinksList($query);
	return $re ?? [];
}

// 获取友链分页
function getLinksPage($args = '')
{
	$obj = \FC\obj('\Main\Api\App\data');
	$query = $obj->query($args);
	$page = $obj->page['links'];
	return $obj->page($query, $page);
}

// 获取评论列表
function getCommentsList($args = '')
{
	$urls = parse_url(NOW_URL);
	$obj = \FC\obj('\Main\Api\App\data');
	$query = $obj->query($args);
	$query['page_name'] = $urls['path'];
	$re = $obj->getCommentsList($query);
	return $re ?? [];
}

// 获取评论分页
function getCommentsPage($args = '')
{
	$obj = \FC\obj('\Main\Api\App\data');
	$query = $obj->query($args);
	$page = $obj->page['comments'];
	return $obj->page($query, $page);
}
